﻿using System;
namespace Xtee.Riik.Ee.Xsd.Xtee {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="legacy_response", Namespace="http://x-tee.riik.ee/xsd/xtee.xsd", Target=typeof(LegacyResponse))]
    public class LegacyResponseSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected ILegacyResponse clazz;
        
        public LegacyResponseSerializer(ILegacyResponse clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("url");
            if (clazz.Url!=null) {
                Writer.WriteTypeAttribute("http://x-tee.riik.ee/xsd/xtee.xsd", "url");
                Writer.WriteString(clazz.Url.ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Url");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="url") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>legacy_response>url");
                }
                clazz.Url = new global::Xtee.Riik.Ee.Xsd.Xtee.Url(Reader.ReadElementString("url"));
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>legacy_response>url", Reader.LocalName);
            }
        }
    }
}
